import { Mt, MtEntity } from '@/api/manager/mt'
import { ListChildComponentProps } from 'react-window'
// export class RollTerMode {
// 	/**终端对象*/
// 	mcc: MtEntity
// 	/**mtKey */
// 	mtKey: string
// 	/**点名状态 */
// 	callState: 0 | 1
// 	constructor(mt: MtEntity) {
// 		this.mcc = mt
// 		this.mtKey = mt.mt_key
// 		this.callState = 0
// 	}
// }
export interface MtTranslateRollEntity extends MtEntity {
	mtId?: string
	mtKey?: string
	confE164?: string | undefined
	oftenMt?: number | undefined
	interactiveMt?: number | undefined
	accountType?: number
	mtType?: number
}
export interface RollEntity {
	name: string
	mode: number
	state?: number
	roll_call_sign_enable: number
	roll_caller: MtTranslateRollEntity[]
	cur_roll_caller: MtTranslateRollEntity
	roll_callee: MtTranslateRollEntity[]
	cur_roll_callee: MtTranslateRollEntity
	roll_callee_pass: MtTranslateRollEntity[]
	roll_callee_no_call: MtTranslateRollEntity[]
	roll_callee_no_pass: MtTranslateRollEntity[]
}
export interface RollTranslateEntity {
	preName: string
	mode: number
	state?: number
	rollCallSignEnable: boolean
	/** 点名人列表*/
	rollcaller: MtTranslateRollEntity[]
	/** 被点名人列表*/
	rollcallee: MtTranslateRollEntity[]
	/**当前选择点名人终端 */
	curRollcaller: MtTranslateRollEntity
	/**当前选择被点名人列表中终端 */
	curRollcallee: MtTranslateRollEntity
	rollcalleePass: MtTranslateRollEntity[]
	rollcalleeNocall: MtTranslateRollEntity[]
	rollcalleeNopass: MtTranslateRollEntity[]
}
// const translateData = (data: RollEntity): RollTranslateEntity => {
// 	if (data) {
// 		return {
// 			preName: data.name /**预案名 */,
// 			mode: data.mode /**点名模式1-vmp;2-点名人(默认值);3-被点名人 */,
// 			state: data.state /**点名状态 */,
// 			rollCallSignEnable: Boolean(data.roll_call_sign_enable) /**点名签到表按钮是否可用 */,
// 			rollcaller: data.roll_caller.map((item) => translateMt(item)) /**历史点名人 */,
// 			rollcallee: data.roll_callee.map((item) => translateMt(item)) /**被点名人列表-所有人 */,
// 			curRollcaller: translateMt(data.cur_roll_caller) /**当前点名人 */,
// 			curRollcallee: translateMt(data.cur_roll_callee) /**当前被点名人 */,
// 			rollcalleePass: data.roll_callee_pass.map((item) => translateMt(item)) /**被点名人列表-通过 */,
// 			rollcalleeNocall: data.roll_callee_no_call.map((item) => translateMt(item)) /**被点名人列表-未被点名 */,
// 			rollcalleeNopass: data.roll_callee_no_pass.map((item) => {
// 				return translateMt(item)
// 			}) /**被点名人列表-未通过 */,
// 		}
// 	}
// 	return data
// }
/**轮询终端*/
export interface TerMode {
	mcc: Mt
	status: {
		checked: boolean
		pass: number
		/**备注框显示*/
		remarkTrue?: boolean
		/**点名状态*/
		call_state?: boolean
		isOnline: boolean
	}
	/**备注信息*/
	remark: string
	mtKey: string
	number: string
	mtId?: string
	confE164?: string | undefined
	oftenMt?: number | undefined
	interactiveMt?: number | undefined
	accountType?: number
	mtType?: number
}
/**
 * 转换轮询终端拖拽转换终端
 * @param source 轮询终端
 * @returns 展示数据
 */
export const ListTranslator = (source: Array<MtEntity & { remark?: string }>): TerMode[] => {
	return source.map((item) => {
		const mt = item
		return {
			mcc: new Mt(mt),
			status: {
				checked: false,
				pass: 2,
				remarkTrue: false,
				isOnline: !!mt.online,
			},
			mtKey: mt.mt_key || mt.e164 || '',
			number: '',
			remark: mt.remark ?? '',
		}
	})
}
//拖拽终端参数
export interface terminalEntity {
	mts: TerMode[]
	from: string | undefined
	dropIndex: number
}
/**接口返回预案实体 */
export type PlanResponseEntity = Array<{
	name: string
	id: string
}>
/**转换后预案数据*/
/**comted消息推送mcc_meeting_mix*/
export interface CometdMtEntity {
	mcc_message_type: 'mcc_meeting_mix'
	e164: string
	meeting_moid: string
	message_type: 'MCC_MESSAGE'
	data: {
		name: string
		mode: 1 | 2
		state: 0 | 1
		members: Array<MtEntity>
	}
}
export interface RowRendererProps extends ListChildComponentProps {
	data: Array<TerMode>
}
/**预案详情返回数据 */
export type PlanResponseRollEntity = {
	id: string
	members: MtTranslateRollEntity[]
	mode: number
	name: string
}
